home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / latticeAutoparent.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.4 KB  |  89 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Alias|Wavefront Script File
  19. // MODIFY THIS AT YOUR OWN RISK
  20. //
  21. // Creation Date:  19 May 1997
  22. // Author:         bb
  23. //
  24. //
  25. //  Procedure Name:
  26. //      lattice autoparent
  27. //
  28. //  Description:
  29. //              Verify that only a single object is selected.
  30. //              If so, create a lattice that deforms the given 
  31. //              object and parent the lattice and its base lattice
  32. //              to the given object.
  33. //
  34. //  Input Arguments:
  35. //      None.
  36. //
  37. //  Return Value:
  38. //      None.
  39. //
  40. global proc latticeAutoparent(string $latticeCmd) {
  41.     string $sArr[2] = `ls -sl -tail 2`;
  42.  
  43.     // verify that only a single item is selected
  44.     //
  45.     if (1 != size($sArr)) {
  46.         error("Autoparent cannot be used when more than one item is selected.");
  47.         return;
  48.     }
  49.  
  50.     string $ffdResult[];
  51.     string $ffdNode;
  52.     string $selectedItem = $sArr[0];
  53.     
  54.     // execute the given command string
  55.     //
  56.     if (catch($ffdResult = `eval($latticeCmd)`)) {
  57.         return;
  58.     }
  59.     $ffdNode = $ffdResult[0];
  60.  
  61.     // parent either:
  62.     //   latticeGroup if single transform method was used,
  63.     //   else lattice and base lattice
  64.     //
  65.     string $parents[2] = `listRelatives -p`;
  66.     $sArr = `ls -sl -tail 2`;
  67.  
  68.     if (size($sArr) > 0) {
  69.         string $newLattice = $sArr[0];
  70.         
  71.         if (size($parents) > 0) {
  72.             // lattice group
  73.             //
  74.             parent $parents[0] $selectedItem;
  75.             select $newLattice;
  76.         } else {
  77.             parent $sArr[0] $selectedItem;
  78.  
  79.             // parent lattice and base lattice
  80.             //
  81.             $sArr = `listConnections ($ffdNode+".blm")`;
  82.             if (size($sArr) > 0) {
  83.                 parent $sArr[0] $selectedItem;
  84.             }
  85.             select $newLattice;
  86.         }
  87.     }
  88. }
  89.